evalin('base','load NEDC.mat'); % Load power cycle into base workspace

SOC = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
Voc_charge = [2.59 3.22 3.26 3.3 3.3 3.31 3.31 3.32 3.34 3.34 3.47;
              2.59	3.22 3.26 3.3 3.3 3.31 3.31	3.32 3.34 3.34 3.47;
              2.62	3.22 3.26 3.29 3.31	3.31 3.31 3.32 3.34	3.34 3.49];
          
Voc_discharge = [2.66	3.19	3.23	3.26	3.28	3.28	3.29	3.3	3.33	3.33	3.4;
                 2.59	3.2	    3.23	3.26	3.29	3.29	3.29	3.3	3.33	3.33	3.47;
                 2.62	3.2	    3.23	3.26	3.29	3.29	3.29	3.3	3.33	3.33	3.49];
             
% R0_charge = [0.0306	0.0123	0.0126	0.012	0.0117	0.012	0.0117	0.0123	0.012	0.0144	0.0207;
%                0.0291	0.0081	0.0084	0.0084	0.0078	0.0081	0.0078	0.0096	0.0081	0.0096	0.0138;
%                0.0315	0.0063	0.0069	0.0069	0.006	0.0063	0.006	0.0078	0.0069	0.0072	0.0366];

R0_discharge = [0.0771	0.0168	0.0135	0.0123	0.0117	0.0123	0.0117	0.012	0.0117	0.0114	0.012;
                  0.0504	0.0108	0.009	0.0093	0.0081	0.0081	0.0078	0.0087	0.0084	0.0081	0.009;
                  0.0609	0.0102	0.0072	0.0075	0.0063	0.0063	0.006	0.0069	0.0066	0.0063	0.0075];

R0_charge = R0_discharge;

R1_charge = [0.032155	0.008199	0.004763	0.004183	0.00348	0.003242	0.003193	0.003006	0.003091	0.003062	0.003062;
             0.012504	5.41E-4	    0.003537	0.003003	4.5E-4	4.39E-4	    0.002547	0.002464	0.0024	     0.00235	0.00235;
              0.00427	0.00182	    0.001322	0.001046	8.96E-4	8.39E-4	     8.55E-4	8.66E-4	    8.09E-4	     8.2E-4	     8.2E-4];
 

R1_discharge = [0.032155	0.008199	0.004763	0.004183	0.00348	0.003242	0.003193	0.003006	0.003091	0.003062	0.003062;
                0.012504	5.41E-4	    0.003537	0.003003	4.5E-4	4.39E-4	    0.002547	0.002464	0.0024	    0.00235	    0.00235;
                0.00427	    0.00182	    0.001322	0.001046	8.96E-4	8.39E-4	    8.55E-4	    8.66E-4	    8.09E-4	    8.2E-4	    8.2E-4];


C1_discharge = [54.148429	21.802633	25.586141	30.914925	26.854337	32.525752	40.18035	1.503165	44.76751	43.347833	43.347833;
                126.757565	124027.8913	170.870475	10.644622	91198.21109	116446.6892	273.943487	267.03323	258.336018	66.112471	66.112471;
                370.397856	79.309163	123.464355	153.608202	184.623885	216.481651	248.348676	251.671468	249.628226	255.665342	255.665342];


C1_charge = C1_discharge;

assignin('base','SimpleResistive',evalin('base','Simulink.Variant(''Mode == 1'')'));
assignin('base','TheveninRC',evalin('base','Simulink.Variant(''Mode == 2'')')); 


assignin('base','HeatEst_SimpleR', evalin('base','Simulink.Variant(''Mode == 1'')'));
assignin('base','HeatEst_TheveninRC', evalin('base','Simulink.Variant(''Mode == 2'')'));


assignin('base','SOC',SOC);
assignin('base','Voc_charge',Voc_charge);
assignin('base','Voc_discharge',Voc_discharge);
assignin('base','R0_discharge',R0_discharge);
assignin('base','R0_charge',R0_charge);
assignin('base','R1_discharge',R1_discharge);
assignin('base','R1_charge',R1_charge);
assignin('base','C1_discharge',C1_discharge);
assignin('base','C1_charge',C1_charge);

assignin('base','Mass_Batt',200);   % in Kg
assignin('base','Cp',0.85);        % in J/Kg/K

assignin('base','Hysterisis',1);

% Run Simulation
evalin('base', ' sim(''Battery_Model.slx'') ');

